package com.wzb.mybatisplus.bitaction.electrumaction.one;

import java.math.BigInteger;

public class PracticalHexExample {

    /**
     * 加密货币地址处理（示例）
     */
    public static void cryptoAddressExample() {
        // 比特币椭圆曲线参数中的十六进制值
        String[] secp256k1Params = {
                "79BE667E", "F9DCBBAC", "55A06295", "CE870B07", "029BFCDB", "2DCE28D9",
                "59F2815B", "16F81798", "483ADA77", "26A3C465", "5DA4FBFC", "0E1108A8",
                "FD17B448", "A6855419", "9C47D08F", "FB10D4B8"
        };

        System.out.println("=== SECP256K1 曲线参数 ===");
        for (String hex : secp256k1Params) {
            BigInteger decimal = new BigInteger(hex, 16);
            System.out.println(hex + " = " + decimal);
        }
    }

    /**
     * 颜色值转换（十六进制RGB）
     */
    public static void colorConversion() {
        String colorHex = "79BE667E"; // RGBA 颜色值

        if (colorHex.length() == 8) {
            BigInteger colorValue = new BigInteger(colorHex, 16);
            System.out.println("颜色值: #" + colorHex);
            System.out.println("十进制: " + colorValue);

            // 分解为RGBA组件
            int r = (colorValue.intValue() >> 24) & 0xFF;
            int g = (colorValue.intValue() >> 16) & 0xFF;
            int b = (colorValue.intValue() >> 8) & 0xFF;
            int a = colorValue.intValue() & 0xFF;

            System.out.println("RGBA: R=" + r + ", G=" + g + ", B=" + b + ", A=" + a);
        }
    }

    public static void main(String[] args) {
        cryptoAddressExample();
        System.out.println();
        colorConversion();
    }
}